<template>
  <div>
    <el-link type="primary" @click="openHandle">{{ value }}</el-link>

    <dictionary-item
      v-if="visibleItem"
      :typeId="id"
      :type="type"
      :visible="visibleItem"
      @onClose="closeHandle"
    />
  </div>
</template>

<script>
  import DictionaryItem from '../../dictionary-item'
  export default {
    name: 'dictionary-type',
    props: {
      value: {
        type: String,
        default: ''
      },
      scope: {
        type: Object,
        default: null
      }
    },
    data () {
      return {
        visibleItem: false,
        id: null,
        type: ''
      }
    },
    components: {
      DictionaryItem
    },
    methods: {
      // 打开字典项弹窗
      openHandle () {
        let id = this.scope.row.id
        let type = this.scope.row.type
        this.visibleItem = true
        this.id = id
        this.type = type
      },
      // 关闭字典项弹窗
      closeHandle (visible) {
        this.visibleItem = visible
      }
    }
  }
</script>

<style scoped>

</style>
